# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=phodav
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0
pkgrel=2
arch=('any')
pkgdesc="A WebDAV server using libsoup (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-libsoup")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "gtk-doc")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://www.gnome.org"
source=(https://download.gnome.org/sources/${_realname}/${pkgver}/${_realname}-$pkgver.tar.xz
        001-win.patch)
sha256sums=('53b42faf2d6edfb0072dbbbe9b8360d8603cca2cacd142df8d1781b9ba0cb9ed'
            '2480a0b804924fd1cfa3dd6a949cdb2250d487cead2f1b1d30ba8cf8e3ec0246')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  patch -b -V simple -p1 -i ${srcdir}/001-win.patch

  autoreconf -isf
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  mkdir -p doc/reference/html
  cp -rf ../${_realname}-${pkgver}/doc/reference/html/* doc/reference/html

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/lib${_realname}/COPYING"
}
